//
//  FamilyUserCell.m
//  AILock
//
//  Created by 谭亚明 on 2020/7/16.
//  Copyright © 2020 tym. All rights reserved.
//

#import "FamilyUserCell.h"
#import "UIView+ZFFrame.h"
#import "UIImageView+YPImage.h"
@interface FamilyUserCell ()

@property(nonatomic,weak) UIImageView *headImage;
@property(nonatomic,weak) UIImageView *appImage;
@property(nonatomic,weak) UILabel *nameLab;

@property(nonatomic,weak) UIImageView *rightImage;
@end


@implementation FamilyUserCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}



-(void)initUI{
    
    UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_home3"]];
    image.frame = CGRectMake(15, 10, 50, 50);
    image.layer.cornerRadius = 25;
    image.layer.masksToBounds = YES;
    image.contentMode = UIViewContentModeScaleAspectFill;
    [self.contentView addSubview:image];
    self.headImage = image;
    
    UIImageView *appImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tag_phone"]];
    appImage.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:appImage];
    appImage.frame = CGRectMake(image.zf_right-17, image.zf_bottom - 20 , 17, 17);
    self.appImage = appImage;
    
    UILabel *moblib = [TYMLabel lb_text:@"" font:Font_Medium(15) color:rgba(74, 74, 74)];
    moblib.frame = CGRectMake(75, 12.5, 150, 21);
    [self.contentView addSubview:moblib];
    self.nameLab = moblib;
    
    UILabel *type = [TYMLabel lb_text:@"" font:Font_Regular(12) color:rgba(155, 155, 155)];
    type.frame = CGRectMake(75, 41, 150, 21);
    [self.contentView addSubview:type];
    self.typeLab = type;
    
    UIImageView *right = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_list_more"]];
    right.frame = CGRectMake(ScreenWidth - 28-30, 26, 18, 18);
    [self.contentView addSubview:right];
    self.rightImage = right;
}

-(void)setUserModel:(UserModel *)userModel{
    if (userModel.nickname) {
        _nameLab.text = userModel.nickname;
    }else{
        _nameLab.text = userModel.mobile;
    }
    _typeLab.text = [userModel getTypeStr];
    if (userModel.type==1) {
        self.appImage.hidden = NO;
    }else{
        self.appImage.hidden = YES;
    }
    if(userModel.headImgUrl.length){
        [_headImage yp_setImageUlr:userModel.getEquipmentImage];
    }else{
        _headImage.image = [UIImage imageNamed:@"icon_home3"];
    }
}

+(CGFloat)cellForHeight{
    return 70;
}

+(NSString*)identifier{
    return @"FamilyUserCell";
}


-(void)rightImageHidden{
    self.rightImage.hidden = YES;
}

@end
